import request, {requestString} from '../../utils/request'

/**
 * 分页查询付款
 *
 * @param receiver		供应商名称（收款人）
 * @param status		状态 0.删除 1.草稿 2.待审核 3.待付款 4.已付款 5.已拒绝
 * @return
 */
export async function getListForPage(data) {
    return request(apiPath.mc + "/api/payment", {
        method: 'get',
        data
    });
}

/**
 * 新增付款
 *
 * @param paymentForm
 * @param bindingResult
 * @return
 */
export async function createPayment(data) {
    return requestString(apiPath.mc + "/api/payment", {
        method: 'post',
        data
    });
}


/**
 * 更新付款
 *
 * @param paymentForm
 * @param bindingResult
 * @return
 */
export async function updatePayment(data) {
    return requestString(apiPath.mc + "/api/payment", {
        method: 'put',
        data
    });
}

/**
 * 根据id获取付款
 *
 * @param id
 * @return
 */
export async function getPaymentById({ id }) {
    return request(apiPath.mc + "/api/payment/" + id, {
        method: 'get'
    });
}



/**
 * 根据付款id查询已核销的费用
 *
 * @param paymentId
 */
export async function getVerificatedByPaymentId(data) {
    return request(apiPath.mc + "/api/payment/" + data.paymentId + "/verificated", {
        method: 'get',
        data
    });
}


/**
 * 付款核销费用
 *
 * @param paymentId
 * @param feeId
 * @param amount
 * @return
 */


export async function verificate({ paymentId, feeId, amount }) {
    return request(apiPath.mc + "/api/payment/" + paymentId + "/unClaim", {
        method: 'POST',
        data: { paymentId, feeId, amount }
    });
}



/**
 * 取消核销费用
 *
 * @param id
 * @return
 */

export async function cancelVerificate({ id }) {
    return request(apiPath.mc + "/api/payment/" + id + "/cancelVerificate", {
        method: 'POST',
        data: { id }
    });
}
